
import sys
from PySide6.QtCore import QUrl,Qt
from PySide6.QtMultimedia import QAudioOutput,QMediaPlayer,QMediaFormat
from PySide6.QtMultimediaWidgets import QVideoWidget
from PySide6.QtWidgets import QMainWindow,QApplication

def get_supported_mime_types():
    result=[]
    for f in QMediaFormat().supportedFileFormats(QMediaFormat.Decode):
        mime_type=QMediaFormat(f).mimeType()
        result.append(mime_type.name())
    return result


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self._audio_output=QAudioOutput()
        self._player=QMediaPlayer()
        self._player.setAudioOutput(self._audio_output)
        self._video_widget=QVideoWidget()
        self.setCentralWidget(self._video_widget)
        self._player.setVideoOutput(self._video_widget)
        self.setWindowFlag(Qt.FramelessWindowHint)        #将界面设置为无框
        self._playlist = []  # FIXME 6.3: Replace by QMediaPlaylist?
        self._playlist_index = -1
        self._audio_output.setVolume(0.2)   #设置音量,范围(0-1)

        
        
    def play(self):
        fp='E:\project\shapimage\Video_20240107175504.wmv'
        self._player.setSource(QUrl.fromLocalFile(fp)) 
        self._player.play()
        
if __name__=='__main__':
    app=QApplication(sys.argv)
    main_win=MainWindow()
    available_geometry=main_win.screen().availableGeometry()
    # main_win.resize(available_geometry.width()/3,\
    #     available_geometry.height()/2)
    main_win.resize(available_geometry.width(),\
    available_geometry.height())
    main_win.show()
    main_win.play()
    # main_win.resize(1020,720)                      #设置播放窗口大小
    # main_win._audio_output.setVolume(0.2)               #设置播放音量

    sys.exit(app.exec())
    